<div class="content-box"><!-- Start Content Box -->
    <div class="content-box-header">

        <h3>Slide</h3>

        <ul class="content-box-tabs">

            <li><a href="index.php?page=lienket">Table</a></li> <!-- href must be unique and match the id of target div -->
            <li><a href="#tab2" class="default-tab">Forms</a></li>
        </ul>

        <div class="clear"></div>

    </div> <!-- End .content-box-header -->

    <div class="content-box-content">



        <div class="content-box-tabs" id="tab2">        <div class="bot"></div>
    
<?php
$hide_show=1;
$ten='';$anh='';$txt_link='';$caption='';
if(isset($_POST['txt_link']))	
	{
		$txt_link=$_POST['txt_link'];
		$hide_show=0;
	}
	if(isset($_POST['anh']))		$anh=$_POST['anh'];
	if(isset($_POST['caption']))	$caption=$_POST['caption'];
	if($hide_show==1)
		
	{
		$sql='SELECT * FROM tbl_slide WHERE id = "'.$id.'"';
		$res=mysql_query($sql);
		$row=mysql_fetch_array($res);
?>
    <form  name="frnn" action="" method="post" enctype="multipart/form-data">
        <fieldset>
        <div style="float:left;width:100%">
            <p>
            	<label>Ảnh slide</label>
                <img src="../js/data1/images/<?php echo $row['image']?>" width="130" height="80"/>
                <input name="anh" type="file"/>
            </p>
            <p>
            	<label>Link slide</label>
                <input name="txt_link" id="txt_link"  value="<?php echo $row['link']?>"  class="medium-input" type="text" maxlength="255" >
            </p>
            <p>
	            <label>Caption slide</label>
                <input name="caption" id="caption"  value="<?php echo $row['caption']?>"  class="medium-input" type="text" maxlength="255" >
            </p>    
                <br><br><br><br>
         </div>  
        
            <p>
                <button class="btn" type="reset">Nhập lại</button>
                <button class="btn" type="submit" name="submit" 
                	style="width:100px; background:#0066FF; border:none; height:22px; color:#FFFFFF; border-radius:2px; cursor:pointer">Cập nhật</button>
            </p>
         </fieldset>   
    </form>
    <?php
	}else
	{
		//Define some variables  
$dir = "../js/data1/images/"; //Bạn nên thay đổi đường dẫn cho phù hợp
//Kiều file, Gif, jpeg, zip ::bạn có thể sửa đổi nếu thích 
$types = array("image/gif","image/GIF","image/JPG","image/PNG","image/png","image/jpg","image/JPEG","image/jpeg","application/x-zip-compressed","application/msword","application/vnd.ms-excel");     
//Check to determine if the submit button has been pressed  
if(isset($_POST["submit"])){ 
//Shorten Variables  
     $tmp_name = $_FILES["anh"]["tmp_name"];  
     $new_name = $_FILES["anh"]["name"]; 
//Check MIME Type  
    if (in_array($_FILES["anh"]["type"], $types)){                     
         //Move file from tmp dir to new location  
        move_uploaded_file($tmp_name,$dir . $new_name);    
		$anh=$new_name;        
        echo "<script>alert('File {$_FILES["anh"]["name"]} đã gửi xong!');</script>"; 
    }else{                 
    //Print Error Message  
     echo "<script>alert('{$_FILES["anh"]["name"]} Ảnh không được thay thế!');</script>";       
    
    }       
    }       
else{       
    echo 'Không có file upload';   
}  	
	if($anh==''){
		$sql3_1='	UPDATE 	tbl_slide
								SET 	
										link="'.$txt_link.'",
										caption="'.$caption.'"
										 
								WHERE id='.$id.'';
		
		}else{
		$sql3_1='	UPDATE 	tbl_slide
								SET 	
										image="'.$anh.'",
										link="'.$txt_link.'",
										caption="'.$caption.'"
										 
								WHERE id='.$id.'';
	}
		$res3_1=mysql_query($sql3_1);
		if(isset($sql3_1))
		{
			?>
            <script>alert('Sửa Thành Công ! ');</script>
            <?php
			header('refresh:0; index.php?page=slide');
		}
		if(!isset($sql3_1))
		{
			?>
            <script>alert('Sửa Thất bại ! ');</script>
            <?php
		}
	}
	?>

             
        </div>
    </div>
</div>